package com.heima.article.listener;
import com.alibaba.fastjson.JSON;
import com.heima.article.service.ApArticleService;
import com.heima.common.constants.message.HotArticleConstants;
import com.heima.model.article.mess.ArticleVisitStreamMess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class ArticleIncrHandleListener {
    @Autowired
    private ApArticleService articleService;
    @KafkaListener(topics = HotArticleConstants.HOT_ARTICLE_INCR_HANDLE_TOPIC)
    public void receiveMessage(String messStr){
        log.info("收到实时文章行为信息，重新计算文章分值   messStr=>{}",messStr);
        ArticleVisitStreamMess mess = JSON.parseObject(messStr, ArticleVisitStreamMess.class);
        articleService.updateApArticle(mess);
    }
}